package holdobject;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import static net.mindview.util.Print.print;

public class SetOperations {
    public static void main(String[] args) {
        Set<String> set1=new HashSet<String>();
        Collections.addAll(set1,"A B C D E F G H I J K L".split(" "));//字符分割成数组
        set1.add("M");
        print(set1);
        print("H: "+set1.contains("H"));//此集合包含指定元素，则返回true
        print("N: "+set1.contains("N"));
        Set<String> set2=new HashSet<String>();
        Collections.addAll(set2,"H I J K L".split(" "));
        print(set2);
        print("set2 in set1:"+set1.containsAll(set2));//此集合包含指定元素集合，则返回true
        set1.remove("H");
        print("set1:"+set1);
        set1.removeAll(set2);
        print(set1);
        Collections.addAll(set1,"X Y Z".split(" "));//括号里面的第一个是哪一个集合，逗号后面的是插入的元素
        print(set1);

    }
}
